﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MySQLLib
{
    public class Other
    {
        public static System.Array ResizeArray(System.Array oldArray, int newSize)
        {
            int oldSize = oldArray.Length;
            System.Type elementType = oldArray.GetType().GetElementType();
            System.Array newArray = System.Array.CreateInstance(elementType, newSize);
            int preserveLength = System.Math.Min(oldSize, newSize);
            if (preserveLength > 0)
                System.Array.Copy(oldArray, newArray, preserveLength);
            return newArray;
        }

        public static int[] toIntArray(string[] array)
        {
            int[] newarray = new int[array.Length];
            string str;

            for (int i = 0; i < array.Length; i++)
            {
                str = array[i];
                newarray[i] = Convert.ToInt32(str);
            }

            return newarray;
        }

        public static void ResizetwoDimensArray(ref string[,] original, int cols, int rows)
        {
            string[,] newArray = new string[rows, cols];

            Array.Copy(original, newArray, original.Length);

            original = newArray;
        }
    }
}
